<?php

 /**
  * @package JooS
  * @subpackage Syntax_PHPackager
  */

  require_once "JooS/Syntax/Complex/Transition.php";

  class JooS_Syntax_PHPackager_DOM_Name extends JooS_Syntax_Complex_Transition {
    /**
     * @return string
     */
    public function compile() {
      $ret = parent::compile();
      if ($ret !== false) {
        $ret = strtolower($ret);
      }
      return $ret;
    }

    /**
     * @return JooS_Syntax_Complex_Concatenate
     */
    public function createRule() {
      $parser = $this->getParser();
      
      return $parser->createSyntax("Complex_Concatenate", array(
        $parser->createSyntax("Except", $parser->createSyntax("Simple_None"), $parser->createSyntax("Simple_Digit")),
        $parser->createSyntax("Complex_Repetition", $parser->createSyntax("Complex_Choose", array(
          $parser->createSyntax("Simple_Character"),
          $parser->createSyntax("Simple_Digit"),
        )), 0, 1), 
        $parser->createSyntax("Complex_Repetition", $parser->createSyntax("Complex_Concatenate", array(
          $parser->createSyntax("Simple_Symbol", "_"),
          $parser->createSyntax("Complex_Repetition", $parser->createSyntax("Complex_Choose", array(
            $parser->createSyntax("Simple_Character"),
            $parser->createSyntax("Simple_Digit"),
          )), 0, 1), 
        )))
      ));
    }
  }
